<template>
  <div>
    <h3>这里是主视图组件</h3>
    {{count}}
       {{addCount}}
    <span v-if="info.age !== 0">
      {{info}}
    </span>
    <div>
      <button @click="incrase">+</button>
      <button @click="jianfa">-</button>
      <button @click="addInfo">addInfo</button>
    </div>
  </div>
</template>
<script>
  import MethodName from '../store/mthodName/testName.js';
  export default {
    data() {
      return {
        name: "MainVm",
        age: 0
      }
    },
    computed: {
      count() {
        return this.$store.state.a.count;
      },
      info(){
        return this.$store.state.a.info;
      },
      addCount(){
        return this.$store.getters.addCount;
      }
    },
    methods: {
      incrase(){
        this.$store.commit(MethodName.TEST_INCREMENT,20);
      },
      jianfa(){
        this.$store.commit(MethodName.TEST_DECREMENT,2);
      },
      addInfo(){
        // this.$store.commit('addInfo',{
        //   name:"shiqinlong",
        //   age:12,
        //   address:'shanxi'
        // })
        this.$store.dispatch('setInfo');
      }
    }
  }
</script>
<style scoped>

</style>
